package com.moss.cloud.auth.biz.config;

import com.moss.cloud.auth.biz.service.ISysMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 初始化资源池信息
 * @auhtor 瑾年
 * @data 2023年3月7日
 */
@Component
@Slf4j
public class AuthInitializedEvent {

    private final ISysMenuService sysMenuService;
    public AuthInitializedEvent(ISysMenuService sysMenuService){
        this.sysMenuService = sysMenuService;
    }

    @Bean
    @Order
    @EventListener({WebServerInitializedEvent.class})
    public void loadSysMenuAttributes() {
        log.info("正在初始化系统菜单资源...");
        sysMenuService.loadSysMenu();
    }
}
